home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
M2Crypto
/
m2urllib.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
2KB
|
69 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
import string
import sys
import urllib
from urllib import *
import SSL
import httpslib
DEFAULT_PROTOCOL = 'sslv23'
def open_https(self, url, data = None, ssl_context = None):
if ssl_context is not None and isinstance(ssl_context, SSL.Context):
self.ctx = ssl_context
else:
self.ctx = SSL.Context(DEFAULT_PROTOCOL)
user_passwd = None
if type(url) is type(''):
(host, selector) = splithost(url)
if host:
(user_passwd, host) = splituser(host)
host = unquote(host)
realhost = host
else:
(host, selector) = url
(urltype, rest) = splittype(selector)
url = rest
user_passwd = None
if string.lower(urltype) != 'http':
realhost = None
else:
(realhost, rest) = splithost(rest)
if realhost:
(user_passwd, realhost) = splituser(realhost)
if user_passwd:
selector = '%s://%s%s' % (urltype, realhost, rest)
if not host:
raise IOError, ('http error', 'no host given')
if user_passwd:
import base64 as base64
auth = string.strip(base64.encodestring(user_passwd))
else:
auth = None
h = httpslib.HTTPSConnection(host = host, ssl_context = self.ctx)
if data is not None:
h.putrequest('POST', selector)
h.putheader('Content-type', 'application/x-www-form-urlencoded')
h.putheader('Content-length', '%d' % len(data))
else:
h.putrequest('GET', selector)
if auth:
h.putheader('Authorization', 'Basic %s' % auth)
for args in self.addheaders:
apply(h.putheader, args)
h.endheaders()
if data is not None:
h.send(data + '\r\n')
resp = h.getresponse()
fp = resp.fp
return urllib.addinfourl(fp, resp.msg, 'https:' + url)